"use strict";
const electron = require("electron");
const path = require("path");
process.env["ELECTRON_DISABLE_SECURITY_WARNINGS"] = "true";
const createWindow = () => {
  const win = new electron.BrowserWindow({
    width: 800,
    height: 600,
    autoHideMenuBar: true,
    // 隐藏顶部工具栏
    title: "中科学钱班-教师端",
    // icon: join(__dirname, '../public/icon.png'),
    webPreferences: {
      sandbox: false,
      webSecurity: false,
      allowRunningInsecureContent: true,
      // 如果你的视频内容是非安全的，需要这个设置
      nodeIntegration: true,
      // 设置是否在页面中启用 Node.js 集成模式
      contextIsolation: false
      // 设置是否启用上下文隔离模式。
    }
  });
  if (process.env.VITE_DEV_SERVER_URL) {
    win.loadURL(process.env.VITE_DEV_SERVER_URL);
    win.webContents.openDevTools();
  } else {
    win.loadFile(path.join(__dirname, "../dist/index.html"));
  }
};
electron.app.whenReady().then(() => {
  createWindow();
  electron.app.on("activate", () => {
    if (electron.BrowserWindow.getAllWindows().length === 0) createWindow();
  });
});
electron.app.on("window-all-closed", () => {
  if (process.platform !== "darwin") electron.app.quit();
});
